﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Linq;

namespace UtilZ.Dotnet.Ex.ParaManagement
{
    /// <summary>
    /// 参数转换器
    /// </summary>
    public interface IParaConverter
    {
        /// <summary>
        /// 尝试将内存参数值转写到XElement中[写入成功返回true,失败返回false]
        /// </summary>
        /// <param name="paraItemEle">参数项元素</param>
        /// <param name="paraName">参数名称</param>
        /// <param name="value">参数值对象</param>
        /// <returns>写入成功返回true,失败返回false</returns>
        bool TryWriteTo(XElement paraItemEle, string paraName, object value);

        /// <summary>
        /// 尝试从XElement中中读取内存参数值[读取成功返回true,失败返回false]
        /// </summary>
        /// <param name="paraItemEle">参数项元素</param>
        /// <param name="paraName">参数名称</param>
        /// <param name="value">结果参数值对象</param>
        /// <returns>读取成功返回true,失败返回false</returns>
        bool TryReadFrom(XElement paraItemEle, string paraName,  out object value);
    }

}
